import pymysql  # MySQL 适用

def getCanteenIdList():
    # 连接数据库
    conn = pymysql.connect(host="localhost", user="root", password="123456", database="esl")
    cursor = conn.cursor()

    # 执行查询（从第 7 条开始）
    query = "SELECT canteen_id FROM canteen where canteen_id != '52f94d0fea0e4244af14536b1fe42436';"
    cursor.execute(query)

    # 获取数据
    rows = cursor.fetchall()

    # 输出结果
    # for row in rows:
    #     print(row[0],row[1],row[2])

    # 关闭连接
    cursor.close()
    conn.close()
    return rows



if __name__ == "__main__":
    rows = getCanteenIdList()
    for index,row in enumerate(rows):
        print(index,row)
    print(rows.__len__())


